%% This code plots Cash Flow Forecasts
% Campbell_Shiller_UK plot
clearvars -except Globaloption option

if exist('Globaloption','var')==0
    Globaloption.savefig=1;
end


loaddata_4CIjoint_annual;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run ../../tools/cashflow_1yr.m

ttime = [1793:1946];

startColor = [0.5, 0.5, 0.5];

f = figure;
plot(ttime(2:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(2:T), ts_var1y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(2:T), ts_ols1y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse1y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse1y_dt(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_1yr_dt_cy_pre', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(2:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(2:T), ts_var1y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(2:T), ts_ols1y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse1y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse1y_dg(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_1yr_dg_cy_pre', '-dpdf', '-fillpage');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 5-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


run ../../tools/cashflow_5yr.m

f = figure;
plot(ttime(6:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(6:T), ts_var5y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(6:T), ts_ols5y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse5y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse5y_dt(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_5yr_dt_cy_pre', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(6:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(6:T), ts_var5y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(6:T), ts_ols5y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse5y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse5y_dg(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_5yr_dg_cy_pre', '-dpdf', '-fillpage');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 10-year
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run ../../tools/cashflow_10yr.m

f = figure;
plot(ttime(11:T), ts_actual_dt, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(11:T), ts_var10y_dt, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(11:T), ts_ols10y_dt, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse10y_dt(1))], ...
    ['OLS, rmse=', num2str(rmse10y_dt(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Tax/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_10yr_dt_cy_pre', '-dpdf', '-fillpage');
end

f = figure;
plot(ttime(11:T), ts_actual_dg, 'LineWidth', 2, 'Color', 'black');
hold on
plot(ttime(11:T), ts_var10y_dg, '-', 'LineWidth', 2, 'Color', startColor + 0.25);
hold on
plot(ttime(11:T), ts_ols10y_dg, '--', 'LineWidth', 2, 'Color', startColor - 0.25)
legend('Data', ['VAR, rmse=', num2str(rmse10y_dg(1))], ...
    ['OLS, rmse=', num2str(rmse10y_dg(2))], 'location', 'northwest')
set(gca, 'FontName', 'Times New Roman')
grid
ylabel('\Delta Log Spending/GDP')
xlim([1793, 1946])
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/US/pre1946/forecast_10yr_dg_cy_pre', '-dpdf', '-fillpage');
end
